<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>鑫立方管理系统</title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/common.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/main.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/designer.css" />
<script type="text/javascript" src="<%=basePath%>js/libs/modernizr.min.js"></script>

<script src="<%=basePath%>js/jquery-1.10.2.min.js"></script>
</head>
<body>
  <script type="text/javascript" src="<%=basePath%>js/wz_tooltip.js"></script>
  <div class="topbar-wrap white">
    <div class="topbar-inner clearfix">
      <div class="topbar-logo-wrap clearfix">
        <ul class="navbar-list clearfix">
          <li><a class="on" href="#">鑫立方管理系统</a>
          </li>
        </ul>
      </div>
      <div class="top-info-wrap">
        <ul class="top-info-list clearfix">
          <li><a href="/user/logout">退出</a>
        </ul>
      </div>
    </div>
  </div>
  <div class="container clearfix">
    <div class="sidebar-wrap">
      <div class="sidebar-content">
        <ul class="sidebar-list">
          <li><a href="#"><i class="icon-font">&#xe003;</i>主材部</a>
            <ul class="sub-menu">
              <li><a href="<%=basePath + "product/index"%>"><i class="icon-font">&#xe008;</i>商品管理</a></li>
              <li><a href="<%=basePath + "factory/product"%>"><i class="icon-font">&#xe006;</i>厂家管理</a></li>
              <li><a href="<%=basePath + "order/index"%>"><i class="icon-font">&#xe005;</i>订单管理</a></li>
              <c:if test="${sessionScope.xlf_userType == '10' }">
                <li><a href="<%=basePath + "user/index"%>"><i class="icon-font">&#xe009;</i>管理员管理</a></li>
              </c:if>
              <li><a href="<%=basePath + "product/mail"%>"><i class="icon-font">&#xe004;</i>邮件配置</a></li>
               <li><a href="<%=basePath + "email/index"%>"><i class="icon-font">&#xe012;</i>邮件记录</a>
              </li>
            </ul>
          </li>
        </ul>
      </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">
      <div class="crumb-wrap">
        <div class="crumb-list">
          <i class="icon-font"></i><a href="/product/index">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">订单管理</span>
        </div>
      </div>
      <div class="result-wrap">
        <jsp:useBean id="planList" class="com.xlf.cache.PlanList" />
        <jsp:useBean id="orderStatusList" class="com.xlf.cache.OrderStatusList" />
        <table class="insert-tab" width="100%">
          <tr>
            <td colspan="4"><h3>订单信息</h3></td>
          </tr>
          <tr>
            <td style="text-align:right; padding-right:10px;">订单编号</td>
            <td><input type="text" class="common-text" value="${order.o_id }" readonly="readonly">&nbsp;&nbsp;&nbsp;&nbsp;${orderStatusList.getName(order.status) }</td>
            <td style="text-align:right; padding-right:10px;">创建日期</td>
            <td><input type="text" class="common-text" value="<fmt:formatDate value="${order.createTime }" pattern="yyyy-MM-dd" />" readonly="readonly"></td>
          </tr>
          <tr>
            <td style="text-align:right; padding-right:10px;">套餐类型</td>
            <td><input type="text" class="common-text" value="${planList.getName(order.planType) }" readonly="readonly"></td>
            <td style="text-align:right; padding-right:10px;">订单价格</td>
            <td>
              <input type="text" class="common-text" value="${order.price }" readonly="readonly">&nbsp;&nbsp;
              <c:if test="${order.discount > 0 }">
                <font color="blue">(${order.discount }&nbsp;折后价格)</font>
              </c:if>            
            </td>
          </tr>
          <tr>
            <td colspan="4"><h3>客户信息</h3></td>
          </tr>
          <tr>
            <td style="text-align:right; padding-right:10px;">客户姓名</td>
            <td><input type="text" class="common-text" value="${order.custerName }" readonly="readonly"></td>
            <td style="text-align:right; padding-right:10px;">客户电话</td>
            <td><input type="text" class="common-text" value="${order.custerTel }" readonly="readonly"></td>
          </tr>
          <tr>
            <td style="text-align:right; padding-right:10px;">客户地址</td>
            <td><input type="text" class="common-text" value="${order.custerAddress }" readonly="readonly"></td>
            <td style="text-align:right; padding-right:10px;">房屋面积</td>
            <td><input type="text" class="common-text" value="${order.roomSize }" readonly="readonly">&nbsp;&nbsp;&nbsp;&nbsp;
            <c:if test="${not empty order.contractPic }">
              <a href="<%=basePath %>upload/contract/${order.contractPic }" target="_blank">合同照片</a>
            </c:if>
            </td>
          </tr>
        </table>
        
        <div style="padding-top:20px; padding-bottom:10px;"><h3>订单明细</h3></div>
        <c:forEach items="${orderCatalogs }" var="orderCatalog" varStatus="s">
        <table class="insert-tab" width="100%">
          <c:if test="${order.planType == 4 }">
            <c:set var="colspanSize" value="12"></c:set>
          </c:if>
          <c:if test="${order.planType != 4 }">
            <c:set var="colspanSize" value="11"></c:set>
          </c:if>
            <c:if test="${orderCatalog.getOrderItems().size() > 0 }">
              <tr>
                <td colspan="${colspanSize }"><h3>${orderCatalog.name }</h3></td>
              </tr>
              <tr>
                <c:if test="${orderCatalog.c_id == 9 }">
                  <td>名称</td>
                </c:if>
                <c:if test="${orderCatalog.c_id != 9 }">
                  <td>图片</td>
                  <td>品牌</td>
                  <td>型号</td>
                  <td>规格</td>
                  <td>材质</td>
                </c:if>
                <td>单位</td>
                <c:if test="${order.planType == 4 }">
                  <td>价格</td>
                </c:if>
                <td>数量</td>
                <td>使用位置</td>
                <td>备注</td>
                <c:if test="${orderCatalog.c_id != 9 }">
                  <td>量尺时间</td>
                  <td>送货时间</td>
                </c:if>
              </tr>
              <c:forEach items="${orderCatalog.getOrderItems() }" var="orderItem" varStatus="s">
              <tr>
                <c:if test="${orderCatalog.c_id == 9 }">
                  <td>${orderItem.get('brand') }</td>
                </c:if>
                <c:if test="${orderCatalog.c_id != 9 }">
                  <td>
                  <a href="#" onmouseover="TagToTip('span${orderItem.get('p_id') }');" onmouseout="UnTip();"><img src="<%=basePath %>upload/${orderItem.get('pic') }" border="0" class="product_img"/></a>
                  <span id="span${orderItem.get('p_id') }">
                    <img src="<%=basePath %>upload/${orderItem.get('pic') }" width="196px" height="196px">
                  </span>
                  </td>
                  <td>${orderItem.get('brand') }</td>
                  <td>${orderItem.get('type') }</td>
                  <td>${orderItem.get('spec') }</td>
                  <td>${orderItem.get('material') }</td>
                </c:if>
                <td>${orderItem.get('unit') }</td>
                <c:if test="${order.planType == 4 }">
                  <td>${orderItem.get('price') }</td>
                </c:if>
                <td>${orderItem.get('count') }</td>
                <td>${orderItem.get('location') }</td>
                <td>${orderItem.get('itemRemark') }</td>
                <c:if test="${orderCatalog.c_id != 9 }">
                  <td>
                    <c:if test="${empty orderItem.get('scaleTime') }"><font color="red">待确认</font></c:if>
                    <c:if test="${not empty orderItem.get('scaleTime') }">${orderItem.get('scaleTime') }</c:if>
                  </td>
                  <td>
                    <c:if test="${empty orderItem.get('deliverTime') }"><font color="red">待确认</font></c:if>
                    <c:if test="${not empty orderItem.get('deliverTime') }">${orderItem.get('deliverTime') }</c:if>
                  </td>
                </c:if>
              </tr>
              </c:forEach>
              <tr>
                <td colspan="${colspanSize }">补充说明(特殊工艺或造型)</td>
              </tr>
              <tr>
                <td colspan="${colspanSize }">${orderCatalog.catalogRemark }</td>
              </tr>
            </c:if>
        </table>
        <div style="height: 10px;"></div>
        </c:forEach>
        <table class="insert-tab" width="100%">
          <tr>
            <td><h3>订单备注（增减项说明）</h3></td>
          </tr>
          <tr>
            <td>${order.orderRemark }</td>
          </tr>
        </table>
        <div style="height: 10px;"></div>
        <table class="insert-tab" width="100%">
          <c:if test="${order.status == 0 }">
          <tr>
            <td style="text-align: center;">
              <a class="btn btn-info btn6 mr10" href="detail?print=true&oid=${order.o_id }" target="_blank">打印订单</a>&nbsp;&nbsp;
              <input type="button" class="btn btn-primary btn6 mr10" value="审核通过" onclick="window.location.href='orderApply?oid=${order.o_id}&status=1';">&nbsp;&nbsp;
              <input type="button" class="btn btn-danger btn6" value="删除订单" onclick="del('${order.o_id }');">
            </td>
          </tr>
          </c:if>
          <tr>
            <td style="text-align: center;">
              <input type="button" class="btn btn6" onclick="window.location.href='/order/index'" value="返回" type="button">
            </td>
          </tr>
          <c:if test="${order.status == 1 }">
          <tr>
            <td style="text-align: center;">
              <input type="button" class="btn btn-success btn6" onclick="window.location.href='orderApply?oid=${order.o_id}&status=2';" value="订单完结" type="button">
            </td>
          </tr>
          </c:if>
        </table>
      </div>
    </div>
    <!--/main-->
  </div>
  <script type="text/javascript">
  function del(oid) {
  	if(confirm("确定删除此订单?")) {
  	  window.location.href = "/order/orderDel?doid=" + oid; 
  	}
  }
  </script>
</body>
</html>